$(document).ready(function () {
    getArray();
 })

function getArray() {
    getDepArray();
}


function depAppand(data) {
    var array = data;
    var table = "<tr>\n" +
        "                        <th>序号</th>\n" +
        "                        <th>系名</th>\n" +
        "                        <th>操作</th>\n" +
        "                    </tr>";
    for (var i = 0; i < array.length; i++) {
        table += "<tr>\n" +
            "                        <td>" + array[i].id + "</td>\n" +
            "                        <td>" + array[i].name + "</td>\n" +
            "<td >" + "<a href='#' onClick='changeWindow(" + array[i].id + ")'>修改</a>" + "|" +
            "<a href='#' onClick='deleteData(" + array[i].id + ")'>删除</a>"
            + "</td>\n";
        table += "                    </tr>";
    }
    $("#depTable").empty()
    $("#depTable").append(table);
}

function changeWindow(id) {
    window.open('update.html?id=' + id, 'new', 'location=no, toolbar=no');
    return false;
}

function deleteData(data) {
    if (!confirm("警告！！！删除系部会将其下所有用户与评分同时删除，你确定删除吗？")) {
        return false;
    }
    $.ajax({
        "url": url + deleteChangeUrl + data,
        "type": 'post',
        "dataType": "json",
        "success": function (data) {
            var res = eval('(' + JSON.stringify(data) + ')');
            if (res.resultCode != 200) {
                error(data);
                return;
            }
            alert("删除成功！")
            location.reload([bForceGet]);
        },
        "error": error()
    })
}